package com.chinatelecom.check.controller;

import com.chinatelecom.check.entity.CheckTaskOrg;
import com.chinatelecom.check.model.CheckTaskOrgModel;
import com.chinatelecom.check.service.CheckTaskOrgService;
import com.chinatelecom.framework.model.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import com.chinatelecom.framework.model.PageParam;
import com.chinatelecom.framework.model.R;

import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;



@Api(tags="CheckTaskOrg接口")
@RestController
@RequestMapping(value="/CheckTaskOrg")
@Slf4j
public class CheckTaskOrgController  {
	
	private final String info_prefix = "[CheckTaskOrg模块]";

	@Autowired
	private CheckTaskOrgService checkTaskOrgService;


	@ApiOperation(value="CheckTaskOrg分页列表")
	@GetMapping(value = "list")
	public R list(PageParam param){
		log.debug("{}-列表数据", info_prefix);
		PageData<CheckTaskOrgModel> data =  checkTaskOrgService.page(param);
		return R.ok().data(data);
	}


	@ApiOperation(value="CheckTaskOrg详情")
	@GetMapping("/view/{id}")
	public R view(@PathVariable String id){
		log.debug("{}-查看CheckTaskOrg信息", info_prefix);
		CheckTaskOrgModel data = BeanUtil.toBean(checkTaskOrgService.getById(id), CheckTaskOrgModel.class);
		return R.ok().data(data);
	}
	

	@ApiOperation(value = "新增CheckTaskOrg")
	@PostMapping("add")
	public R add(CheckTaskOrgModel  model) {
		log.debug("{}-新增CheckTaskOrg: {}", info_prefix,  model);
		CheckTaskOrg record = BeanUtil.toBean(model, CheckTaskOrg.class);
		checkTaskOrgService.insert(record);
		return R.ok("新增成功").data(record);
	}

	
	@ApiOperation(value = "根据ID删除CheckTaskOrg")
	@PostMapping("/del/{id}")
	public R del(@PathVariable String id){
		log.debug("{}-根据ID删除", info_prefix, id);
		checkTaskOrgService.delete(id);
		return R.ok("删除成功");
	}

	
	@ApiOperation(value="更新CheckTaskOrg")
	@PostMapping("update")
	public R update(CheckTaskOrgModel  model){
		log.debug("{}-保存信息: {}", info_prefix, model);
		CheckTaskOrg record = BeanUtil.toBean(model, CheckTaskOrg.class);
		checkTaskOrgService.update(record);
		return R.ok("更新成功");
	}
	
	@ApiOperation(value = "查看CheckTaskOrg属性")
	@GetMapping("/model")
	public CheckTaskOrg model() {
		return null;
	}
	
}
